package com.sheledon.flyCat.factory;

import com.sheledon.flyCat.annotation.aop.Aspect;
import com.sheledon.flyCat.annotation.boot.Component;
import com.sheledon.flyCat.annotation.ioc.Bean;
import com.sheledon.flyCat.annotation.ioc.Configuration;
import com.sheledon.flyCat.annotation.springmvc.RestController;
import com.sheledon.flyCat.common.utils.ReflectionUtils;

import java.lang.annotation.Annotation;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class ClassFactory {
    private static final Class<? extends Annotation> [] annotations =
            new Class[]{RestController.class, Component.class
                    , Aspect.class, Configuration.class,
                    Bean.class};
    public static Map<Class<? extends Annotation>, Set<Class<?>>> CLASS_FACTORY = new HashMap<>();
    public static void loadClass(String [] packageNames){
        for (Class<? extends Annotation> ca : annotations){
            Set<Class<?>> classes = ReflectionUtils.scanAnnotationClass(packageNames,ca);
            ClassFactory.CLASS_FACTORY.put(ca,classes);
        }
    }
}
